<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title></title>
	<meta name="format-detection" content="telephone=no"/>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../css/list.css" />
</head>
<body>
	<div class="h10"></div>	 
	<div id="divTipInfo" style="text-align:center;font-size:14px;color:#999"></div> 
	<div id="main_content"></div>
  	<div id="divNoDataTip">
		<div id="textTip" style="margin-top:10px;margin-bottom:10px;width:100%;text-align: center;" 
			class="button red" tapmode="">正在加载....</div>
	</div> 
	<div class="h10"></div>
</body>
<script type="text/javascript" src="../script/api.js"></script>  
<script type="text/javascript" src="../script/alpenlicebe.js"></script>   
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script> 
<script type="text/javascript" src="../script/echarts-all.js"></script> 
<script>
	apiready = function(){ 
 		/*下拉刷新*/
    	api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/refresh.png',
            bgColor: '#fff',
            textColor: '#000',
            textDown: '下拉刷新...',
            textUp: '松开刷新...',
            showTime: true
        }, function (ret, err) {  
        	$("#main_content").html(""); 
        	$("#textTip").html("正在加载..");
            goto_loadDataFun();
            api.refreshHeaderLoadDone();
        }); 
 
        /*初始化加载数据*/
       	goto_loadDataFun();   
	}  
	
    function goto_loadDataFun() {  
        goto_loadNewsListFun(); 
        api.parseTapmode();  
    } 
	function goto_loadNewsListFun(){  
		var userID=Alpe_getLocalStorge('access_token');  
    	if(''==userID){
    		api.alert({title:'系统提示',msg:'您未登录'});
			return;
    	}
    	var cateID=api.pageParam.cateID;
    	var cateName=api.pageParam.cateName;
    	var cateInfo=api.pageParam.cateInfo;
		if(''==cateID||undefined==cateID||null==cateID
		||''==cateInfo||undefined==cateInfo||null==cateInfo){
    		api.alert({title:'系统提示',msg:'参数错误'});
			return;
    	}
		 
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '',
		    text: '',
		    modal: false
		});

		var MD5 = new Hashes.MD5;   
       	var access_token = Alpe_getLocalStorge("access_token");                     
       	var admin_id = Alpe_getLocalStorge("admin_id"); 
       	var sign = MD5.hex(access_token+admin_id+cateInfo+'1.0syjqingbao');
            
       	var url = Alpe_ApiUrl+'r='+cateInfo+'&access_token='+access_token+'&admin_id='+admin_id
       		+'&v=1.0&sign='+sign;
       	api.ajax({
	         url: url,
	         method: 'get',
	         cache: false,
	         timeout: 30,			
	         dataType: 'json'
       	}, function(ret, err){  
			if (ret) {	 
				if(ret.success == '100'){ 
					/*工作考核datas/SkH*/
					if('100'==cateID){
						$("#divTipInfo").html("本月实时数据");
						goto_tj_table(ret.list,ret.img);
					}else{
 						if('datas/SmonitorDatas'==cateInfo){
 							$("#divTipInfo").html("最近一周数据");
                           list_statistics_line(ret.x,ret.y);
                       	}
                     	else if('datas/SdealDatas'==cateInfo){
                     		$("#divTipInfo").html("最近半年数据");
                        	list_statistics_line(ret.weeks_line.months_x,ret.weeks_line.months_y);
                        }
                        else if('datas/SareaDatas'==cateInfo){
                        	$("#divTipInfo").html("本月实时数据");
                        	list_statistics_line(ret.city_list.x,ret.city_list.y);
                        }
					}	  
				}else if("002"==ret.success||"003"==ret.success){ 
					goto_openWin_loginWin(ret.message);
				}else{	  
                 	$("#textTip").html(ret.message);			 
					api.toast({
		         		msg: ret.message,
                 		duration:2000,
                    	location: 'middle'
               		});         
		  		}
		  		$("#textTip").html("");
		  		api.hideProgress();
			}else{
				api.alert({title:'系统提示',msg:'错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode});
				api.hideProgress();
			} 
   		});
	}
function list_statistics_line(x,y){
      
      var persons = x.persons;
      var number = eval(x).length;
      var min_number = 6;
      var max_number = 12;
      document.getElementById('main_content').style.height = '400px'; 
      if(number < 4){
          document.getElementById('main_content').style.width = '100%';      
      }else if(number > 4 && number < 12){
          document.getElementById('main_content').style.width = '140%';
        
      }else if(number > 12){
          document.getElementById('main_content').style.width = '200%';
      } 
 
     var myChart = echarts.init(document.getElementById('main_content'));
         api.showProgress({
			        style: 'default',
			        animationType: 'fade',
			        title: '',
			        text: '',
			        modal: true
			     });
        myChart.setOption({
            tooltip : {
                trigger: 'axis'
            },
             toolbox: {
                show : true,
                feature : {
                    
                    magicType : {show: true, type: ['line', 'bar']},
                    
                }
            }, 
            xAxis : [
                {
                    type : 'category',
                    data : x
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    splitArea : {show : true}
                }
            ],
            series : [
                {
                    name:'条数',
                    type:'bar',
                    data:y
                }
            ]
        });
         api.hideProgress();
         $("#text").html('');
    } 
	function goto_tj_table(dataList,imgList){
		$("#main_content").html('');
        document.getElementById('main_content').style.width = '100%';
    	var html = '<table width="90%" align="center" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000"><tr align="center"><td>地市</td><td>未处置<br />(百分比)</td><td>处置中<br />(百分比)</td><td>处置完成<br />(百分比)</td><td>总量</td></tr>';
     	$.each(dataList, function (key, value){
			html += '<tr align="center"><td>'+value.city_name+'</td><td>'+value.count[0][1]+'('+value.count[0][0]+'%)</td><td>'+value.count[1][1]+'('+value.count[1][0]+'%)</td><td>'+value.count[2][1]+'('+value.count[2][0]+'%)</td><td>'+value.num+'</td></tr>';	
		});
		html +='</table>';
		for (img in imgList){ 
			html +='<br/>';
		 	html+="<a onclick=gotoShowPicFun('"+imgList[img]+"')><img src='"+imgList[img]+"' style='width:98%' /> </a>"; 
		} 
		$("#main_content").html(html);		     
    }
	function gotoShowPicFun(pic){
		if('ios'==api.systemType){
        	api.openApp({
			    iosUrl: pic
			},function(ret,err){
			     
			});
        }
        if('android'==api.systemType){
        	api.openApp({
			    androidPkg: 'android.intent.action.VIEW',
			    
			    uri: pic
			},function(ret,err){ 
			});
        }	    
	}
    
</script>
</html>